#ifndef Tui_TLabel_h
#define Tui_TLabel_h

#include "TScale9.h"
#include "TBase.h"
#include "cocos-ext.h"
USING_NS_CC_EXT;

using namespace rapidxml;

class TextFormat{
public:
    TextFormat( int nWidth=0,
                int nHeight=0,
                int nFontSize=15,
                ccColor3B color=ccc3(255, 255, 255),
                CCTextAlignment alignh=kCCTextAlignmentCenter,
                CCVerticalTextAlignment alignv=kCCVerticalTextAlignmentTop);
    
    int nWidth;
    int nHeight;
    int nFontSize;
    ccColor3B color;
    CCTextAlignment alignH;
    CCVerticalTextAlignment alignV;
    
};


class TLabel:public TPanelItem{
    
public:
    TLabel();
    ~TLabel();
    static TLabel* create(const TextFormat& format,const char* txt=NULL);
    
    CREATE_FUNC(TLabel);
    
    
    static TLabel* create(xml_node<> * pItem);
    virtual  void initWidthConf(xml_node<> * pItem);
    virtual  void initWidthFormat(const TextFormat& format,const char* txt=NULL);
    
    void setString(const char*);
    void setString(const string &);
    void setString(int);
    int getNum();
    const char* getString();
    void setColor(const ccColor3B& color);
    virtual void onStringChange();
    
    void setVerticalAlignment(CCVerticalTextAlignment) ;
    void setHorizontalAlignment(CCTextAlignment alignment);
    CCLabelTTF* m_pLabel;
};



class TInput:public TPanel,public CCEditBoxDelegate{
public:  
    TInput();
    CREATE_FUNC(TInput);
    
    virtual bool init();
     
    static TInput* create(xml_node<> * pItem);   
    virtual  void initWidthConf(xml_node<> * pItem);
    void setString(const char* str);
    virtual void editBoxEditingDidBegin(CCEditBox* editBox);
    virtual void editBoxEditingDidEnd(CCEditBox* editBox);
    virtual void editBoxTextChanged(CCEditBox* editBox, const std::string& text);
    virtual void editBoxReturn(CCEditBox* editBox) ;
    const char* getString();
protected: 
    CCEditBox* m_pEditor;
};



CCLabelTTF*  createLabel(  const TextFormat& format,const char* label="");




CCLabelTTF*  createLabel(int nWidth,int nHeight,int nFontSize=15,
                         ccColor3B color=ccc3(255, 255, 255),
                         CCTextAlignment alignh=kCCTextAlignmentCenter,
                         CCVerticalTextAlignment alignv=kCCVerticalTextAlignmentCenter);






class TStrokeLabel:public TLabel{
    
public:
    TStrokeLabel(); 
    CREATE_FUNC(TStrokeLabel); 
    virtual  void initWidthConf(xml_node<> * pItem); 
    
    static TStrokeLabel* create(int nWidth,int nHeight,int nFontSize=15,
                                 ccColor3B color=ccc3(255, 255, 255),
                                 CCTextAlignment alignh=kCCTextAlignmentCenter,
                                 CCVerticalTextAlignment alignv=kCCVerticalTextAlignmentCenter);
    
    float strokeSize;
    ccColor3B strokeColor;
    int strokeAlpha; 
    
    virtual void onStringChange();
    void initStroke();
    
protected:
    void initStrokeLabel(int nWidth,int nHeight,int nFontSize=15,
                         ccColor3B color=ccc3(255, 255, 255),
                         CCTextAlignment alignh=kCCTextAlignmentCenter,
                         CCVerticalTextAlignment alignv=kCCVerticalTextAlignmentCenter);
    
    CCRenderTexture* m_pStroke;
};


#endif
